package com.dz.controller;


import com.dz.pojo.Information;
import com.dz.service.InformationService;
import com.dz.service.impl.InformationServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dz
 * @since 2021-06-06
 */
@RestController
public class InformationController {
    @Autowired
    private InformationServiceImpl informationService;
    @RequestMapping("/selete")
    public String seleteById(@RequestParam("id")Integer id){
        Information info = informationService.getInfo(id);
        return info.toString();
    }
    //删除用户
    @RequestMapping("/delete")
    public String deleteById(@RequestParam("id")Integer id){
        int res = informationService.deleteById(id);
        if (res!=0)
            return "删除成功";
        else
            return "删除失败";
    }
    //更新用户
    @RequestMapping("/update")
    public String update(){
        Information information = new Information(2, "zsq", "123456", 2);
        int res = informationService.update(information);
        if (res!=0)
            return "更新成功";
        else
            return "更新失败";
    }
}

